cd "D:\MyPapers\Happiness\TWINSDATA\code\2023May-Dataverse"
use twins_PNAS.dta, clear

keep if mz

ivreg health (income=IVincome), robust cluster(twinpair)
outreg2 using TableS8_Endowment.doc,  nolabel replace coefastr se

ivreg married (income=IVincome), robust cluster(twinpair)
outreg2 using TableS8_Endowment.doc,  nolabel append coefastr se

//spouse education and income at the time of marriage
drop if Dedu_spouse_atmarriage==. 
ivreg edu_spouse_atmarriage (income=IVincome), robust cluster(twinpair)
outreg2 using TableS8_Endowment.doc,  nolabel append coefastr se

drop if Dincome_spouse_atmarriage==.
ivreg income_spouse_atmarriage (income=IVincome), robust cluster(twinpair)
outreg2 using TableS8_Endowment.doc,  nolabel append coefastr se

//IVFE

use twins_PNAS.dta, clear
keep if mz

collapse Dincome IVDincome Dhealth Dmarried Dedu_spouse Dedu_spouse_atmarriage Dincome_spouse_atmarriage, by(twinpair)

ivreg Dhealth (Dincome=IVDincome), noc robust
outreg2 using TableS8_Endowment.doc,  nolabel append coefastr se

ivreg Dmarried (Dincome=IVDincome), noc robust
outreg2 using TableS8_Endowment.doc,  nolabel append coefastr se

drop if Dedu_spouse_atmarriage==.
ivreg Dedu_spouse_atmarriage (Dincome=IVDincome), noc robust
outreg2 using TableS8_Endowment.doc,  nolabel append coefastr se

drop if Dincome_spouse_atmarriage==.
ivreg Dincome_spouse_atmarriage (Dincome=IVDincome), noc robust
outreg2 using TableS8_Endowment.doc,  nolabel append coefastr se

clear
exit
